package com.mzj.saas.mservice.sys.utils;

import com.mzj.saas.mservice.department.vo.AddDepartmentPeopleRequestVO;
import com.mzj.saas.mservice.department.vo.DepartmentVO;
import com.mzj.saas.mservice.roles.vo.RoleVO;
import com.mzj.saas.mservice.roles.vo.UserRoleRefVO;
import com.mzj.saas.mservice.sys.vo.PermissionVO;
import com.mzj.saas.mservice.sys.vo.UserVO;
import org.apache.commons.lang3.StringUtils;

public class CheckUtil {

    private boolean flag = false;
    private String message = "";

    public Boolean isNull(){
        return flag;
    }
    public String getMessage(){
        return message;
    }

    public void checkValues(DepartmentVO departmentVO){
        if (departmentVO.getParentId() == null) {
            flag = true;
            this.message = "部门父ID不能为空!";
        }
        if (StringUtils.isBlank(departmentVO.getName())) {
            flag = true;
            this.message = "部门名称不能为空!";
        }
        if (departmentVO.getSortby() == null) {
            flag = true;
            this.message = "排序编号不能为空!";
        }
    }
    public void checkValues(UserRoleRefVO userRoleRefVO){
        if (userRoleRefVO.getUserId() == null) {
            flag = true;
            this.message = "用户ID不能为空!";
        }
        if (userRoleRefVO.getRoleId() == null) {
            flag = true;
            this.message = "角色编号不能为空!";
        }
    }
    public void checkValues(UserVO userVO){
        if (StringUtils.isBlank(userVO.getName())) {
            flag = true;
            this.message = "用户名称不能为空!";
        }
        if (StringUtils.isBlank(userVO.getMobile())) {
            flag = true;
            this.message = "用户手机号不能为空!";
        }
        if (StringUtils.isBlank(userVO.getPassword())) {
            flag = true;
            this.message = "用户密码不能为空!";
        }
    }
    public void checkValues(RoleVO roleVo){
        if (StringUtils.isBlank(roleVo.getName())) {
            flag = true;
            this.message = "名称不能为空!";
        }
    }


    public void checkValues(PermissionVO permissionVO){
        if (permissionVO.getParentId() == null) {
            flag = true;
            this.message = "权限父ID不能为空!";
        }
        if (StringUtils.isBlank(permissionVO.getName())) {
            flag = true;
            this.message = "权限名称不能为空！";
        }
        if (permissionVO.getType() == null) {
            flag = true;
            this.message = "权限类型不能为空！";
        }
        if (StringUtils.isBlank(permissionVO.getCode())) {
            flag = true;
            this.message = "权限编码不能为空！";
        }
//        if (StringUtils.isBlank(permissionVO.getUrl())) {
//            flag = true;
//            this.message = "权限路径不能为空！";
//        }
//        if (StringUtils.isBlank(permissionVO.getMethod())) {
//            flag = true;
//            this.message = "权限方法不能为空！";
//        }
        if (permissionVO.getSortby() == null) {
            flag = true;
            this.message = "排序编号不能为空！";
        }
    }

    public void checkValues(AddDepartmentPeopleRequestVO addDepartmentPeopleRequestVO){
       /* if (org.apache.commons.lang.StringUtils.isBlank(userVO.getLoginName())){
            flag = true;
            this.message = "用户登入名不能为空！";
        }*/
        if (StringUtils.isBlank(addDepartmentPeopleRequestVO.getName())){
            flag = true;
            this.message = "成员姓名不能为空！";
        }
        if (StringUtils.isBlank(addDepartmentPeopleRequestVO.getMobile())){
            flag = true;
            this.message = "成员手机号不能为空";
        }
        if (addDepartmentPeopleRequestVO.getDepId() == null){
            flag = true;
            this.message = "成员所属部门不能为空！";
        }
        if (addDepartmentPeopleRequestVO.getRoleId() == null){
            flag = true;
            this.message = "成员角色不能为空！";
        }
        if (addDepartmentPeopleRequestVO.getPassword() == null){
            flag = true;
            this.message = "密码不能为空！";
        }
        /*if (org.apache.commons.lang.StringUtils.isBlank(userVO.getMobile())){
            flag = true;
            this.message = "用户联系方式不能为空！";
        }*/
//        if (StringUtils.isBlank(userVO.getPassword())){
//            flag = true;
//            this.message = "用户密码不能为空";
//        }
//        if (StringUtils.isBlank(userVO.getConfirmPassword())){
//            flag = true;
//            this.message = "用户确认密码不能为空";
//        }
//
//        if (!Objects.equals(userVO.getPassword(),userVO.getConfirmPassword())){
//            flag = true;
//            this.message = "密码和确认密码不一致";
//        }

    }
}
